﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;

namespace RainyPWS.Model
{
    public class MUser : Model
    {
        public enum ColumnList
        {
            ID,
            UserCode,
            Password,
            UserName,
            Level,
            LastLogin,
            Remark
        }

        private const int MAX_COLUMN_INDEX = 7;

        public MUser()
            : this(true)
        {
        }

        public MUser(bool initDBNull)
            : base(MAX_COLUMN_INDEX, initDBNull)
        {
        }

        public MUser(IDataReader rdr)
        {
            moData = new object[MAX_COLUMN_INDEX];
            rdr.GetValues(moData);
        }


        public int ID
        {
            get
            {
                object o = base.GetValue<ColumnList>(ColumnList.ID);
                if (o == DBNull.Value) return 0;
                return Convert.ToInt32(o);
            }
            set { base.SetValue<ColumnList>(ColumnList.ID, value); }
        }
        public string UserCode
        {
            get
            {
                object o = base.GetValue<ColumnList>(ColumnList.UserCode);
                if (o == DBNull.Value) return string.Empty;
                return o.ToString();
            }
            set { base.SetValue<ColumnList>(ColumnList.UserCode, value); }
        }
        public string Password
        {
            get
            {
                object o = base.GetValue<ColumnList>(ColumnList.Password);
                if (o == DBNull.Value) return string.Empty;
                return o.ToString();
            }
            set { base.SetValue<ColumnList>(ColumnList.Password, value); }
        }
        public string UserName
        {
            get
            {
                object o = base.GetValue<ColumnList>(ColumnList.UserName);
                if (o == DBNull.Value) return string.Empty;
                return o.ToString();
            }
            set { base.SetValue<ColumnList>(ColumnList.UserName, value); }
        }
        public int Level
        {
            get
            {
                object o = base.GetValue<ColumnList>(ColumnList.Level);
                if (o == DBNull.Value) return 0;
                return Convert.ToInt32(o);
            }
            set { base.SetValue<ColumnList>(ColumnList.Level, value); }
        }
        public DateTime LastLogin
        {
            get
            {
                object o = base.GetValue<ColumnList>(ColumnList.LastLogin);
                if (o == DBNull.Value) return DateTime.MinValue;
                return Convert.ToDateTime(o);
            }
            set { base.SetValue<ColumnList>(ColumnList.LastLogin, value); }
        }
        public string Remark
        {
            get
            {
                object o = base.GetValue<ColumnList>(ColumnList.Remark);
                if (o == DBNull.Value) return string.Empty;
                return o.ToString();
            }
            set { base.SetValue<ColumnList>(ColumnList.Remark, value); }
        }

    }
}
